#include<iostream>
using namespace std;

const int stack_size = 300;
int *buffer = new int [stack_size * 3];
int stack_pointer[] = {0,0,0};//stack poiter to track top elem

void push(int stack_num ,int value)
{
	int pos = stack_num*stack_size + stack_pointer[stack_num] + 1;
	buffer[pos] = value;
	stack_pointer[stack_num]++;
}

int pop(int stack_num)
{
	int pos = stack_num * stack_size + stack_pointer[stack_num];
	stack_pointer[stack_num]--;
	int value = buffer[pos];
	buffer[pos] = 0;
	return value;
}

int peek(int stack_num)
{
	int pos = stack_num * stack_size + stack_pointer[stack_num];
	return buffer[pos];
}

bool is_empty(int stack_num)
{
	return stack_pointer[stack_num] == stack_num * stack_size;
}

int main()
{
	for(int i=0;i<30;i++)
	{
		push(i/10,i);
	}
	cout<<peek(0)<<endl;
	cout<<peek(1)<<endl;
	cout<<peek(2)<<endl;
	cout<<is_empty(0)<<" "<<is_empty(1)<<" "<<is_empty(2)<<endl;
	for(int i=0;i<30;i++)
	{
		cout<<pop(i/10)<<" ";
		if(i%10 == 9)
		{
			cout<<endl;
		}
	}
	system("pause") ;
	return 0;
}



